package com.example.navigation

import android.app.Application
import com.tencent.shiply.processor.DiffPkgHandler
import com.tencent.shiply.processor.OriginBasePkgFile
import com.tencent.upgrade.bean.UpgradeConfig
import com.tencent.upgrade.core.UpgradeManager
import dagger.hilt.android.HiltAndroidApp
import com.tencent.upgrade.core.DefaultUpgradeStrategyRequestCallback

/**
 * Created with IntelliJ IDEA.
 * @Author: Liao Run
 * @Date: 2024-06-08 10:23
 * @Description:
 **/
@HiltAndroidApp
class App: Application() {
    // 接入第三方升级支持
    override fun onCreate() {
        super.onCreate()
        // 热更新
        val builder: UpgradeConfig.Builder = UpgradeConfig.Builder()
        val config = builder.appId("b2912b582c")
            .appKey("1ba839c4-c312-4e82-bee2-72afbe2e0f5f")
            .allow32BitApkOn64BitDevice(true) // 64位的系统允许下载32位apk
            .diffPkgHandler(DiffPkgHandler())  //初始化差量包Handler
            .basePkgFileForDiffUpgrade(OriginBasePkgFile())  // 表示基于原始文件生成差量包，不支持渠道包差量
            .build()
        UpgradeManager.getInstance().init(applicationContext, config)


        // 拉取升级任务
        UpgradeManager.getInstance()
            .checkUpgrade(false, null, DefaultUpgradeStrategyRequestCallback())

    }
}